package com.ygou.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import com.ygou.pojo.Websideset;
import com.ygou.service.WebsidesetService;

@Controller
@RequestMapping(value="/web")
public class WebsidesetController {
	@Autowired
	WebsidesetService websidesetService;
	@Autowired
	HttpServletResponse response;

	// 根据主键查询
	@RequestMapping(value ="/selectByPrimaryKey")
	public String selectByPrimaryKey(ModelMap model) {
		Websideset websideset = websidesetService.selectByPrimaryKey(1);
		model.put("websideset", websideset == null ? "" : websideset);
		return "/admin/Systems";
	}
	//根据主键修改
	@RequestMapping(value="/updateByPrimaryKey")
	public void updateByPrimaryKey(Websideset web,HttpServletRequest request) throws IOException{
		PrintWriter out=response.getWriter();
		response.setContentType("text/html;charset=utf-8");
		if(websidesetService.updateByPrimaryKey(web)){
			out.print("<script>" +
					"alert('修改成功');" +
					"location.href='/admin/Systems.jsp'';" +
					"</script>");
		}else{
			out.print("<script>" +
					"alert('修改失败');" +
					"location.href='/admin/Systems.jsp';"+
					"</script>");
		}
	}
}
